package gui;

import javax.microedition.lcdui.game.Sprite;
import logic.LogicHelper;
import logic.MainMidlet;

/**
 * screen for selecting player role in multiplayer game (server or client)
 * @author Rekin
 *
 */
public class ClientServerSelectScreen extends MenuCanvas{
	
	private static String[] menuItemsNames = {
    		"Join Game",
    		"Host Game",
    		"Back",
    };
	
	/**
	 * constructor
	 * @param lab label of this screen
	 */
	public ClientServerSelectScreen(String lab){
		super(menuItemsNames);
	}

	/**
	 * @Override
	 * handles pressing buttons
	 */
	protected void menuItemPressed(int buttonIndex)
	{
		super.menuItemPressed(buttonIndex);
		
		if( buttonIndex == 0){
			MainMidlet.getMidletInstance().setDisplay(
        			new WaitingScreen(LogicHelper.clientWaitingScreen,
        					"Waiting for server...", "Please wait for response..."));
        }
        else if(buttonIndex == 1){
        	MainMidlet.getMidletInstance().setDisplay(
        			new WaitingScreen(LogicHelper.serverWaitingScreen, 
        					"Searching for players...", "Please wait..."));
        }
        else if(buttonIndex == 2){
        	MainMidlet.getMidletInstance().showMainMenu();
        }
	}

	/**
	 * @Override
	 * handles creating selection sprites
	 */
	protected void initSprites() {
		selectionElement1 = new Sprite(LogicHelper.createImageFromResources("/rotatingCards/leftSelectSequence.png", this), 30, 30);
    	selectionElement2 = new Sprite(LogicHelper.createImageFromResources("/rotatingCards/rightSelectSequence.png", this), 30, 30);
	}
}
